<template>
  <div class="cell-a-box">
    <a
      v-if="isUrl(scopeData.row.url)"
      class="a-tag"
      :href="scopeData.row.url || ''"
      target="_blank"
    >
      {{ scopeData.row[tableItem.prop] }}
    </a>
    <span v-else> {{ scopeData.row[tableItem.prop] }} </span>
  </div>
</template>

<script>
export default {
  name: 'CellA',
  props: {
    // 单元格数据
    scopeData: {
      type: Object,
      default: () => ({})
    },
    // 单元格配置项
    tableItem: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {}
  },
  methods: {
    isUrl(url) {
      const str = new RegExp('http')
      return url ? str.test(url) : false
    }
  }
}
</script>

<style lang="scss" scoped>
  .a-tag {
    color: rgb(219,139,57);
  }
</style>
